# 0
# 就是前后带着俩杠

# 1
# 实例化调用第一方法,__new__()

# 2
# 需求需要事,使用init()

# 3
# init方法一定返回None,不能是其他

# 4
# 负责处理构造方法的变量
class CapStr(str):
    def __new__(cls, string: str):
        string = string.upper()
        return str.__new__(cls, string)


a = CapStr('hhahah')
print(a)


# 5
# 当一块内存的所有引用对象都被销毁时,启用del函数

# 动手吧

# 0



class Hua:
    def __new__(cls, temp: int):
        temp = temp * 1.8 + 32
        return temp


hua = Hua(10)
print(hua)


class Zifu(int):
    def __new__(cls, value):
        if isinstance(value,str):
            if len(value) == 1:
                return ord(value)
            elif len(value) > 0:
                temp = 0
                for each in value:
                    temp += ord(each)
                return temp

        else:
            return value


z = Zifu(14)
print(z)
z2 = Zifu('aaa')
print(z2)

